<?php

namespace App;

use Illuminate\Database\Eloquent\Model;

class Supervisor extends Model
{
    protected $fillable = [
        'job', 'title', 'quota', 'major'
    ];

    public function user()
    {
        return $this->belongsTo('App\User');
    }

    /**
     * Get all students.
    */
    public function students()
    {
        return $this->belongsToMany('App\Student')->withPivot('isApproved');;
    }


    public function review_students()
    {
        return $this->belongsToMany('App\Student', "reviewers", "supervisor_id", "student_id");
    }

    public function defense_students()
    {
        return $this->belongsToMany('App\Student', 'defenseteachers', "supervisor_id", "student_id");
    }
}
